﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using My_TV_Manager.View.MenuBar;

namespace My_TV_Manager.View.ContentPanel
{
    [System.ComponentModel.DesignerCategory("")]

    public abstract class InnerTabbedContainer : SplitContainer
    {
        #region Protected Data

        protected InnerMenuBar innerMenuBar;
        protected List<Panel> contentPanels;

        protected double menuBarPercentage;
        protected int menuBarMinimumHeight;

        #endregion

        #region Properties

        public double MenuBarPercentage
        {
            get { return menuBarPercentage; }
            set
            {
                if (value > 1.0) { menuBarPercentage = value / 100.0f; }
                else if (value > 0.0) { menuBarPercentage = value; }
                else { value = 0.1; }
            }
        }

        public int MenuBarMinimumHeight
        {
            get { return menuBarMinimumHeight; }
            set { menuBarMinimumHeight = value; }
        }

        #endregion

        #region Constructors

        public InnerTabbedContainer(Size size)
        {
            // Use the data parameters
            this.Size = size;

            // Format the menu bar height
            menuBarPercentage = 0.08;
            menuBarMinimumHeight = 30;
            this.SplitterDistance = (int)(this.Height * menuBarPercentage);
            if (this.SplitterDistance < menuBarMinimumHeight)
            {
                this.SplitterDistance = menuBarMinimumHeight;
            }

            // Format the split container
            this.Dock = DockStyle.Fill;
            this.Size = size;
            this.Orientation = Orientation.Horizontal;
            this.IsSplitterFixed = true;
            this.FixedPanel = FixedPanel.Panel1;
            this.SplitterWidth = 1;
            this.BorderStyle = BorderStyle.None;

            contentPanels = new List<Panel>();
        }

        #endregion

        #region Functions

        public void ChangeContentPanel(int choice)
        {
            if (contentPanels.Count < choice) { return; }

            this.Panel2.Controls.RemoveAt(0);
            this.Panel2.Controls.Add(contentPanels[choice]);
        }

        #endregion
    }
}
